package com.shop.Result;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class LdbzResult implements Serializable {

    //定义jackson对象
    private static final ObjectMapper MAPPER = new ObjectMapper();

    //响应业务状态
    private Integer status;
    //响应消息
    private String msg;
    //响应数据
    private Object data;
    public static LdbzResult build(Integer status, String msg, Object data) {
        return new LdbzResult(status, msg, data);
    }

    public static LdbzResult ok(Object data) {
        return new LdbzResult(data);
    }

    public static LdbzResult ok() {
        return new LdbzResult(null);
    }

    public static LdbzResult build(Integer status, String msg) {
        return new LdbzResult(status, msg, null);
    }

    public LdbzResult(Object data) {
        this.status = 200;
        this.msg = "OK";
        this.data = data;
    }

    public Boolean isOK() {
        return this.status == 200;
    }

}
